<?php

class heroModel extends Model{
    public function herodis($id){
        $sql = "select a.*,s.img as simg,s.smimg,s.name as sname  from hero a left join h_skin s on a.id = s.hid where a.id = {$id}";
        $data = $this->link->selectByAll($sql);
        $sql2 = "select h.id,
                q.name as qname,q.q_img,q.`describe` as qdescribe,
                w.name as wname,w.w_img,w.`describe` as wdescribe,
                e.name as ename,e.e_img,e.`describe` as edescribe,
                r.name as rname,r.r_img,r.`describe` as rdescribe,
                p.name as pname,p.passive_img,p.`describe` as pdescribe
                from hero h 
                left join h_q q on h.id = q.hid 
                left join h_w w on h.id = w.hid 
                left join h_e e on h.id = e.hid
                left join h_r r on h.id = r.hid
                left join h_passive p on h.id = p.hid
                where h.id = {$id}";
        $str = $this->link->selectByOne($sql2);

        $sql3 = "select b.type from hero a left join herotype b on a.type = b.id where a.id = {$id}";
        $std = $this->link->selectByOne($sql3);
        $dataset['skill'] = $str;
        $dataset['herodata'] = $data;
        $dataset['type'] = $std;
        return $dataset;
    }
}